<?php
// if the variable is not set
if(!isset($x)) {
$x = $_GET['id']; // you can use $_POST depending on how mtype param is configured
}
require_once 'scripts/jq-config2.php';
// include the jqGrid Class
require_once "scripts/jqGrid.php";
// include the driver class
require_once "scripts/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Get the needed parameters passed from the main grid
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query  
$grid->SelectCommand = "SELECT indice, id, giro, fechaV, monto, fechaP, producto, tipo FROM detallescliente";
// Set the table to where you add the data 
$grid->table = 'detallescliente';
// Set output format to json
$grid->dataType = 'json';
// Let the grid create the model//
$grid->setColModel();
// Set the url from where we obtain the data 
$grid->setUrl('gridEdit2.php');
$grid->addCol(array(
    "name"=>"Acciones",
    "formatter"=>"actions",
    "editable"=>false,
    "sortable"=>false,
    "resizable"=>false,
	"height"=>'auto',
    "fixed"=>true,
    "width"=>60,
    "formatoptions"=>array("keys"=>true)
    ), "first");
$grid->setColProperty('indice', array("editable"=>false,"label"=>"Indice","width"=>40));
$grid->setColProperty('id', array("editable"=>false,"label"=>"Id","width"=>40));
$grid->setColProperty('giro', array("editable"=>false,"label"=>"Giros","width"=>110)); 
$grid->setColProperty('fechaV', array("editable"=>true,"label"=>"Vencimiento","width"=>160));
$grid->setColProperty('monto', array("editable"=>true,"label"=>"Monto","width"=>100));
$grid->setColProperty('fechaP', array("editable"=>true,"label"=>"Fecha de Pago","width"=>170));
$grid->setColProperty('producto', array("editable"=>true,"label"=>"Producto","width"=>200)); 
$grid->setColProperty('tipo', array("editable"=>false,"label"=>"Tipo","width"=>60));
$grid->setColProperty('fechaV', 
array("formatter"=>"date",
	"formatoptions"=>array("srcformat"=>"Y-m-d", "newformat"=>"d-m-Y"),
	"editoptions"=>array("dataInit"=>
		"js:function(elm){setTimeout(function(){
			jQuery(elm).datepicker({dateFormat:'dd-mm-yy'});
			jQuery('.ui-datepicker').css({'zIndex':'1200','font-size':'75%'});},100);}")
)); 
$grid->setColProperty('fechaP', 
array("formatter"=>"date",
	"formatoptions"=>array("srcformat"=>"Y-m-d", "newformat"=>"d-m-Y"),
	"editoptions"=>array("dataInit"=>
		"js:function(elm){setTimeout(function(){
			jQuery(elm).datepicker({dateFormat:'dd-mm-yy'});
			jQuery('.ui-datepicker').css({'zIndex':'1200','font-size':'75%'});},100);}")
)); 
$grid->setGridOptions(array(
    "rowNum"=>10,
    "rowList"=>array(10,20,30),
	"height"=>'auto',
	"width"=>600,	
	/* "postData"=>array("id"=>$x), */
    "sortname"=>"giro"
));
$grid->navigator= true;
$grid->setNavOptions('navigator', array("excel"=>false,"add"=>false,"edit"=>false,"del"=>false,"view"=>false, "search"=>false));
$grid->renderGrid('#grid','#pager',true, null, null,  true, true);
$conn = null;
?>